/**
 * 461. 汉明距离
 * https://leetcode-cn.com/problems/hamming-distance/
 */

/**
 * @param {number} x
 * @param {number} y
 * @return {number}
 */
function hammingDistance(x, y) {
  let sum = 0;
  let cur = x ^ y;
  while (cur > 0) {
    sum += (cur & 1);
    cur >>= 1;
  }
  return sum;
}

console.log(hammingDistance(1, 4) === 2);
console.log(hammingDistance(3, 1) === 1);
